package com.chixing.day16_io;

import java.io.*;

/**
 * 字节流:按照字节作为传输单位读写,适用于流媒体二进制的文件传输(图片音频，视频)
 * InputStream OutputStream 抽象父类
 *
 * 字符流:按照字符作为传输单位读写，适用于普通文本读写 本质还是字节流的操作
 * Writer,Reader 抽象父类
 *
 * 带有缓冲区的字符流
 * BuffereWriter BufferedReader
 */
public class BufferedWriterDemo {
    public static void main(String[] args) {
        BufferedWriter bw = null;
        try {
           bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("path")),1024);
                                                      //InputStreamReader
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }

        try {
            bw.write(" ");
            bw.flush();//刷新缓冲区
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            if (bw != null){
                try {
                    bw.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }


            }
        }


    }


      BufferedReader br;

    {
        try {
            br = new BufferedReader(new InputStreamReader((new FileInputStream(""))));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        try {
            br.read();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
